package org.qloudgen.borg.beans;

import java.io.Serializable;
import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.qloudgen.borg.CommonValues;
import org.qloudgen.borg.metadb.ConfigNames;

public class AppBean  implements Serializable{

	private static final long serialVersionUID = 1L;
	
	private String appNo;
	private String appName;
	private String appDesc;
	private int funcCount;
	private List<Cluster> clusters;
	private String clusterStr;
	
	public String getAppNo() {
		return appNo;
	}
	public AppBean setAppNo(String appNo) {
		this.appNo = appNo;
		return this;
	}
	public String getAppName() {
		return appName;
	}
	public AppBean setAppName(String appName) {
		this.appName = appName;
		return this;
	}
	public String getAppDesc() {
		return appDesc;
	}
	public void setAppDesc(String appDesc) {
		this.appDesc = appDesc;
	}
	public int getFuncCount() {
		return funcCount;
	}
	public void setFuncCount(int funcCount) {
		this.funcCount = funcCount;
	}
	
	public String checkAppInfo(){
		
		return checkAppName();
	}
	
	private String checkAppName() {

		if (this.getAppName() == null) return null;
		SqlSession session = CommonValues.factory.openSession();
		int count = (Integer)(session.selectOne(ConfigNames.SELECT_APP_COUNT, this));
		session.close();
		if (count > 0){
			return this.getAppName()+" exists!";
		} else {
			return null;
		}
	}
	public List<Cluster> getClusters() {
		return clusters;
	}
	public void setClusters(List<Cluster> clusters) {
		this.clusters = clusters;
	}
	public String getClusterStr() {
		return clusterStr;
	}
	public void setClusterStr(String clusterStr) {
		this.clusterStr = clusterStr;
	}

}
